

package com.jfinal.aceadmin.model;

import com.jfinal.ext.plugin.tablebind.TableBind;

import java.util.Date;

/**
 * <a href="User.java.html"><b><i>View Source</i></b></a>
 *
 * @author Jason
 *
 */
@TableBind(tableName = "User", pkName = "id")
public class User extends BaseModel<User> {
	private static final long serialVersionUID = 1L;
	public static User dao = new User();

	public int getId() {
		return this.get("id");
	}

	public void setId(int id) {
		this.set("id", id);
	}

	public String getName() {
		return this.get("name");
	}

	public void setName(String name) {
		this.set("name", name);
	}

	public String getEmailAddress() {
		return this.get("emailAddress");
	}

	public void setEmailAddress(String emailAddress) {
		this.set("emailAddress", emailAddress);
	}

	public String getPassword() {
		return this.get("password");
	}

	public void setPassword(String password) {
		this.set("password", password);
	}

	public String getIcon() {
		return this.get("icon");
	}

	public void setIcon(String icon) {
		this.set("icon", icon);
	}

	public Date getCreatedDate() {
		return this.get("createdDate");
	}

	public void setCreatedDate(Date createdDate) {
		this.set("createdDate", createdDate);
	}

	public Date getUpdatedDate() {
		return this.get("updatedDate");
	}

	public void setUpdatedDate(Date updatedDate) {
		this.set("updatedDate", updatedDate);
	}

	public Date getLastLoginDate() {
		return this.get("lastLoginDate");
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.set("lastLoginDate", lastLoginDate);
	}

	public Date getBirthday() {
		return this.get("birthday");
	}

	public void setBirthday(Date birthday) {
		this.set("birthday", birthday);
	}

	public int getAge() {
		return this.get("age");
	}

	public void setAge(int age) {
		this.set("age", age);
	}

	public User findByName(String name) {
		StringBuilder sBuilder = new StringBuilder("SELECT * FROM User WHERE ");
		sBuilder.append("name = ?");

		User result = User.dao.findFirst(sBuilder.toString(), name);

		return result;
	}

	public User findByEmail(String emailAddress) {
		StringBuilder sBuilder = new StringBuilder("SELECT * FROM User WHERE ");
		sBuilder.append("emailAddress = ?");

		User result = User.dao.findFirst(sBuilder.toString(), emailAddress);

		return result;
	}
}